Skip to content

tools, ci: each OpenSSL and libdatachannel configuration is built once, kept by b2 -a and cached by the CI - #29

Merged
pinhopro merged 6 commits into
mainfrom
ci/third-party-cache
Nov 18, 2026
Merged

pinhopro merged 6 commits into
mainfrom
ci/third-party-cache

Conversation

@pinhopro

Copy link
Copy Markdown
Contributor

What changes

Each configuration of OpenSSL and libdatachannel is built once, in a directory its inputs and its command name, and never again, b2 -a included.

  • A configuration's directory is bin/third_party/<name>/config-<hash>. The hash covers two things:
    • the key of the library's inputs (tools/third_party_build.py key: the bytes of its scripts and its pin, after the library's own check_checkout);
    • the values of its build command.
  • A directory that exists therefore holds the build of exactly those inputs and that command, so its outputs are NOUPDATE (tools/webcpp-third-party.jam).
  • The CI's lanes run b2 -a, which used to rebuild every OpenSSL configuration on every run, about 27 minutes each under MSVC.
  • One build per configuration. Consumers whose properties differ only in what the command leaves out now share one build. OpenSSL's C is the same with exception-handling on and off, so the same configuration was built under release/ and again under release/exception-handling-off/. In a local tree, 3 of 12 OpenSSL builds were such repeats.
  • Consumers follow a change of configuration. A consumer depends on the selection of its configuration in its own variant directory: <name>-config-<hash>.selected, which tools/third_party_build.py select writes when the configuration changes, removing the library's other selections there. The consumer is built again even when it switches back to a configuration built earlier, whose directory exists and is older than the consumer.
  • The globs are gone. The glob-tree-ex of the upstream trees, whose modification times decided a rebuild, is removed. It also tripped over OpenSSL's nested submodules when they were checked out.
  • The lint takes a provider's headers from a dry run's header generation too, since a kept configuration's archives are no longer in a dry run.

The CI keeps those directories in a cache (tools/ci/actions/third-party), in the lanes, the own lanes (except OpenSSL's upstream suite, which must run) and the lint (saved by its first shard).

  • The cache belongs to the job and its runner image (ImageOS, ImageVersion). It starts afresh when an input of the builds or a pinned toolchain changes.
  • A job restores the most recent entry under that prefix, and saves only when it built a configuration the cache did not hold, under the hash of the configurations' names.

Two fixes the MSVC run turned up, both older than this change:

  • OpenSSL's VMS headers __DECC_INCLUDE_PROLOGUE.H and __DECC_INCLUDE_EPILOGUE.H were declared outputs on Windows:

    • b2's glob ignores case there, and tools/openssl/build.py never installs them;
    • so every b2 run generated the headers again, which, through the build's dependency on them, used to rebuild OpenSSL too;
    • b2 also printed failed to scan file for them.

    The Jamfile now leaves them out.

  • tools/openssl/test/threads.cpp gave RAND_priv_bytes a size_t, which 64-bit MSVC refuses under /WX (C4267).

What it means for whoever builds

  • b2 -a no longer rebuilds OpenSSL or libdatachannel. To build a configuration again, remove its directory under bin/third_party/<name>/.
  • A checkout that differs from its pin now stops b2 before any build, with the library's own message.

Verified locally

  • tools/third_party_build_test.py: the key, the checkout check and the selection.
  • tools/test/openssl_test.py, including the new cases:
    • test_one_c_configuration_is_built_once: one build for exception-handling=on,off, which built two before.
    • test_a_built_configuration_is_kept_and_selected, with a real build:
      • b2 -a rebuilds the program, not the archives, whose modification time is unchanged;
      • a changed build.py names another directory;
      • the program is rebuilt when its configuration switches to an existing one and back.
  • tools/test/libdatachannel_test.py: b2 -a after a full build rebuilds neither provider.
  • tools/test/cobalt_ssl_test.py, tools/test/openssl_one_copy_test.py, and the lint's provider-header cases.
  • MSVC 14.3 under Wine (the local MSVC lane), on tools/openssl/test//threads:
    • the first run built OpenSSL in bin\third_party\openssl\config-<hash> (42 minutes), with the key and the selection computed under cmd;
    • a second run with -a built no archive, but generated the headers again, which led to the __DECC_ fix;
    • after both fixes, a third run with -a only selected, compiled and linked the program.
  • actionlint, shellcheck of the action's script, Pyright and the lint's pattern rules over the changed files.
  • tools/ci/*_test.py, tools/release/changelog_test.py, tools/report/report_test.py, cobalt_ownership_test, hash_doc_tables_test, hash_jamfiles_test, doc_test and release_test.

Also fixed: main's red tools tests and documentation

Main's last run failed Documentation and Tests of the tools 3/8, 7/8 and 8/8 on one line: the 0.1.0 notes wrote libc++ in prose, whose ++ Asciidoctor reads as a passthrough. It is code now.

On the CI

The first run of this PR fills its caches. A second run should show no webcpp-openssl.build in any lane whose configurations were cached.

To watch

  • Cache size. Each lane and own lane keeps its own cache, about the size of its OpenSSL and libdatachannel configurations (tens of MB each), within the repository's 10 GB, where GitHub evicts the least recently used entries.

🤖 Generated with Claude Code

R added 6 commits November 18, 2026 00:27
…n a directory its inputs and command name, which b2 -a keeps

A configuration's directory is bin/third_party/<name>/config-<hash>, the
hash of the key of the library's inputs (tools/third_party_build.py key:
the bytes of its scripts and its pin, after the library's own
check_checkout) and of its build command. A directory that exists holds
the build of exactly those inputs and that command, so its outputs are
NOUPDATE: built when missing and never again, b2 -a included, which the
CI's lanes run. Consumers whose properties differ only in what the
command leaves out share one build: OpenSSL's C is the same with
exception-handling on and off, which built it twice. The glob of the
upstream trees, whose modification times decided a rebuild, is gone.

A consumer depends on the selection of its configuration in its own
variant directory, which tools/third_party_build.py select writes when
the configuration changes, removing the library's other selections
there, so the consumer is built again even when it changes back to a
configuration built earlier.

The lint takes a provider's headers from a dry run's header generation
too: a kept configuration's archives are no longer in it.
…achannel builds in a cache

tools/ci/actions/third-party restores, before a job's b2, and saves,
after it, bin/third_party/openssl and bin/third_party/libdatachannel,
whose configurations b2 never builds again: a job builds only those its
cache lacks. The cache is the job's, on its runner image (ImageOS and
ImageVersion), and starts afresh when an input of the builds or a pinned
toolchain changes. A job saves it only when it built a configuration the
cache did not hold, under the hash of the configurations' names; the
lint's first shard saves the headers every shard generates. An own lane
that runs OpenSSL's upstream suite neither restores nor saves, so the
suite runs.
…, which b2's case-blind glob on Windows declared and never made, so every run generated the headers again
…as a passthrough, which failed main's documentation and tools tests
…ind of a missing bin/third_party had failed every job under the runner's bash -e -o pipefail

A fresh checkout has no bin/third_party, and a job may build one library alone: find then
exits 1, which pipefail gave the assignment of its output and -e turned into the step's
failure, before any lane ran. key.sh globs the configurations with nullglob instead, under
Bash 3.2 too, which the macOS runners run steps with, and actions_test runs it on a checkout
without builds and on either library's configurations alone, under each Bash it finds.
@pinhopro
pinhopro merged commit 20d1987 into main Nov 18, 2026
541 of 543 checks passed
@pinhopro
pinhopro deleted the ci/third-party-cache branch November 19, 2026 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant